
from enum import Enum

# 色卡方案
# 这枚举值和数值实验室的枚举值对应，数值实验室有15种方案，这里只实现2种
# 后续如果有需要可以把其他的也加进来
class ColorType(Enum):
    Inferno = 1                                # 炽焰色（地狱火色）
    BlueGreenOrange = 2                # 蓝绿橙
    # BlackBlueWhite = 3                        # 黑蓝白
    # BlackBodyRadiation = 4                # 黑体辐射
    # ColdToHot = 5                                # 冷到热
    # CoolToWarm = 6                                # 凉到暖
    # CoolToWarmExtended = 7                # 扩展的凉到暖
    # Fast = 8                                        # 快速
    # LinearGreen = 9                        # 线性绿色
    # RainbowDesaturated = 10                # 去饱和的彩虹色
    # RainbowUniform = 11                        # 均匀彩虹色
    # Turbo = 12                                        # 涡轮色
    # Viridis = 13                               # 绿色渐变
    # XRay = 14                                        # X射线
    YellowGrayBlue = 15                        # 黄灰蓝

# 颜色查找表定义
class ColorLookUpTable:
    # 原始数据
    # 从这个原始数据生成使用中的色卡，原始数据一共256个元素值
    # 应用色卡的颜色值可以比这少，但是无法比这多

    # 炽焰色（地狱火色）
    colors_origin_Inferno = [
        (0.00146487, 0.00047303, 0.0138705),
        (0.00227359, 0.0012665, 0.0185702),
        (0.00329595, 0.00224308, 0.0242466),
        (0.00454719, 0.0033875, 0.0309148),
        (0.00601205, 0.00468452, 0.0385595),
        (0.00767529, 0.00613413, 0.0468299),
        (0.00956741, 0.00770581, 0.0551461),
        (0.0116579, 0.00941482, 0.0634623),
        (0.0139925, 0.0112306, 0.0718547),
        (0.016556, 0.013138, 0.0802777),
        (0.019379, 0.0151369, 0.0887617),
        (0.022446, 0.0171969, 0.097322),
        (0.0257877, 0.0193332, 0.105928),
        (0.0294347, 0.0215, 0.114626),
        (0.0333867, 0.0236973, 0.1234),
        (0.0376745, 0.0259251, 0.132235),
        (0.0422522, 0.0281376, 0.141146),
        (0.0469215, 0.0303197, 0.150164),
        (0.0516365, 0.0324712, 0.159258),
        (0.0564431, 0.0345617, 0.168414),
        (0.0613413, 0.0365911, 0.177646),
        (0.066331, 0.0384985, 0.186969),
        (0.0714275, 0.0402991, 0.196353),
        (0.0766308, 0.0419013, 0.205798),
        (0.0819562, 0.0433356, 0.21529),
        (0.0874037, 0.0445563, 0.224811),
        (0.0929885, 0.0455787, 0.234363),
        (0.0986954, 0.0464027, 0.2439),
        (0.104555, 0.047013, 0.253437),
        (0.110536, 0.0473945, 0.262913),
        (0.116655, 0.0475776, 0.272328),
        (0.122911, 0.0475319, 0.281621),
        (0.12929, 0.0472877, 0.290791),
        (0.135775, 0.0468605, 0.299779),
        (0.142382, 0.0462348, 0.308553),
        (0.149065, 0.0454719, 0.317082),
        (0.155856, 0.0445563, 0.325338),
        (0.162692, 0.0435492, 0.333272),
        (0.169574, 0.0424964, 0.340871),
        (0.176486, 0.0413977, 0.348104),
        (0.183429, 0.0403296, 0.354971),
        (0.190372, 0.0393072, 0.36144),
        (0.197299, 0.038407, 0.367529),
        (0.204211, 0.0376287, 0.373236),
        (0.211093, 0.0370336, 0.378561),
        (0.217945, 0.0366217, 0.38352),
        (0.224765, 0.036408, 0.388128),
        (0.23154, 0.036408, 0.392401),
        (0.23827, 0.0366217, 0.396353),
        (0.244968, 0.0370489, 0.4),
        (0.251621, 0.037705, 0.403372),
        (0.258228, 0.0385748, 0.406485),
        (0.264805, 0.0396429, 0.409339),
        (0.271351, 0.0409247, 0.411978),
        (0.277852, 0.042359, 0.414389),
        (0.284321, 0.0439307, 0.416602),
        (0.290761, 0.0456397, 0.418631),
        (0.297185, 0.0474708, 0.420493),
        (0.303563, 0.0493935, 0.422187),
        (0.309941, 0.0514076, 0.423728),
        (0.316289, 0.0534829, 0.425116),
        (0.322606, 0.0556344, 0.426383),
        (0.328923, 0.0578317, 0.427512),
        (0.33521, 0.0600595, 0.428519),
        (0.341497, 0.0623178, 0.429419),
        (0.347768, 0.064622, 0.430213),
        (0.354025, 0.0669261, 0.4309),
        (0.360281, 0.0692454, 0.431495),
        (0.366522, 0.0715801, 0.431998),
        (0.372763, 0.0739147, 0.432395),
        (0.379004, 0.0762493, 0.432715),
        (0.385229, 0.078584, 0.432959),
        (0.391455, 0.0809339, 0.433112),
        (0.397681, 0.0832532, 0.433188),
        (0.403891, 0.0855726, 0.433173),
        (0.410117, 0.087892, 0.433097),
        (0.416327, 0.0901961, 0.432944),
        (0.422553, 0.0925002, 0.432715),
        (0.428763, 0.094789, 0.43241),
        (0.434989, 0.0970626, 0.432044),
        (0.441215, 0.0993362, 0.431601),
        (0.447425, 0.101595, 0.431083),
        (0.453651, 0.103853, 0.430503),
        (0.459876, 0.106096, 0.429847),
        (0.466102, 0.108324, 0.429129),
        (0.472328, 0.110552, 0.428336),
        (0.478553, 0.112764, 0.427482),
        (0.484794, 0.114977, 0.426551),
        (0.49102, 0.117174, 0.425559),
        (0.497261, 0.119387, 0.424491),
        (0.503487, 0.121569, 0.423362),
        (0.509728, 0.123766, 0.422156),
        (0.515969, 0.125963, 0.42089),
        (0.52221, 0.128145, 0.419547),
        (0.52845, 0.130343, 0.418143),
        (0.534676, 0.13254, 0.416663),
        (0.540917, 0.134722, 0.415122),
        (0.547158, 0.136934, 0.413504),
        (0.553399, 0.139132, 0.411826),
        (0.559625, 0.141344, 0.410071),
        (0.56585, 0.143572, 0.408255),
        (0.572076, 0.1458, 0.406363),
        (0.578302, 0.148043, 0.40441),
        (0.584527, 0.150301, 0.40238),
        (0.590738, 0.15256, 0.40029),
        (0.596933, 0.154849, 0.398123),
        (0.603143, 0.157153, 0.395895),
        (0.609323, 0.159472, 0.393591),
        (0.615518, 0.161822, 0.391226),
        (0.621683, 0.164187, 0.388785),
        (0.627848, 0.166567, 0.386282),
        (0.633997, 0.168994, 0.383703),
        (0.640131, 0.171435, 0.381064),
        (0.646265, 0.173907, 0.378363),
        (0.652369, 0.176425, 0.375586),
        (0.658457, 0.178958, 0.372747),
        (0.664546, 0.181537, 0.369848),
        (0.670604, 0.184146, 0.366873),
        (0.676631, 0.186801, 0.363851),
        (0.682658, 0.189502, 0.360754),
        (0.688655, 0.192233, 0.35761),
        (0.694621, 0.195026, 0.354391),
        (0.700572, 0.197848, 0.35111),
        (0.706493, 0.200732, 0.347784),
        (0.712398, 0.203662, 0.344381),
        (0.718257, 0.206638, 0.340932),
        (0.724102, 0.209674, 0.337423),
        (0.729915, 0.212757, 0.333867),
        (0.735683, 0.2159, 0.330251),
        (0.741421, 0.21912, 0.326574),
        (0.747127, 0.222385, 0.32285),
        (0.752789, 0.225711, 0.319081),
        (0.758419, 0.229099, 0.315267),
        (0.764004, 0.232547, 0.311406),
        (0.769558, 0.236072, 0.307485),
        (0.775051, 0.239673, 0.303532),
        (0.780514, 0.24332, 0.299519),
        (0.785931, 0.247059, 0.295476),
        (0.791287, 0.250858, 0.291386),
        (0.796613, 0.254734, 0.287266),
        (0.801877, 0.258671, 0.283101),
        (0.80708, 0.262699, 0.278904),
        (0.812238, 0.266789, 0.274662),
        (0.817334, 0.270954, 0.27039),
        (0.822385, 0.275196, 0.266087),
        (0.827375, 0.279515, 0.261753),
        (0.832303, 0.283909, 0.257389),
        (0.837171, 0.28838, 0.252995),
        (0.841962, 0.292927, 0.248569),
        (0.846708, 0.297566, 0.244114),
        (0.851377, 0.302266, 0.239643),
        (0.855985, 0.307042, 0.235126),
        (0.860533, 0.311894, 0.23061),
        (0.865003, 0.316823, 0.226062),
        (0.869413, 0.321828, 0.221485),
        (0.873747, 0.326909, 0.216892),
        (0.878004, 0.332067, 0.212268),
        (0.882185, 0.337285, 0.20763),
        (0.886305, 0.34258, 0.202976),
        (0.890333, 0.347951, 0.198291),
        (0.894301, 0.353399, 0.193591),
        (0.898192, 0.358907, 0.188861),
        (0.902007, 0.364492, 0.184115),
        (0.90573, 0.370138, 0.179355),
        (0.909392, 0.37586, 0.174563),
        (0.912963, 0.381643, 0.169757),
        (0.916457, 0.387488, 0.16492),
        (0.919875, 0.393393, 0.160067),
        (0.923217, 0.399359, 0.1552),
        (0.926467, 0.405386, 0.150286),
        (0.929641, 0.411475, 0.145373),
        (0.932738, 0.417624, 0.140414),
        (0.935744, 0.423835, 0.135439),
        (0.938674, 0.430091, 0.130434),
        (0.941527, 0.436408, 0.125414),
        (0.944289, 0.442771, 0.120348),
        (0.94696, 0.449195, 0.115267),
        (0.949569, 0.455665, 0.11017),
        (0.952071, 0.462181, 0.105028),
        (0.954513, 0.468742, 0.0998703),
        (0.956847, 0.475349, 0.0946975),
        (0.959121, 0.482017, 0.0894942),
        (0.961288, 0.488716, 0.0842908),
        (0.963394, 0.49546, 0.0790723),
        (0.965393, 0.502251, 0.0738537),
        (0.967315, 0.509071, 0.0686656),
        (0.969162, 0.515953, 0.0634928),
        (0.970916, 0.52285, 0.0583658),
        (0.972595, 0.529793, 0.0533303),
        (0.974182, 0.536782, 0.0483864),
        (0.975677, 0.543801, 0.0436255),
        (0.977096, 0.550851, 0.0390478),
        (0.978424, 0.557931, 0.0349279),
        (0.97966, 0.565057, 0.0314031),
        (0.980819, 0.572213, 0.0285039),
        (0.981888, 0.579385, 0.0262455),
        (0.982879, 0.586603, 0.0246586),
        (0.98378, 0.593851, 0.0237736),
        (0.984588, 0.601129, 0.0236057),
        (0.985321, 0.608423, 0.0242008),
        (0.985946, 0.615747, 0.0255894),
        (0.986496, 0.623102, 0.0278172),
        (0.986969, 0.630488, 0.0309148),
        (0.987335, 0.637888, 0.0349126),
        (0.987625, 0.645319, 0.0398871),
        (0.987823, 0.652766, 0.0455787),
        (0.98793, 0.660243, 0.0517433),
        (0.987945, 0.66775, 0.0583352),
        (0.987869, 0.675273, 0.0652628),
        (0.987716, 0.682811, 0.0724956),
        (0.987457, 0.690364, 0.0799878),
        (0.987121, 0.697948, 0.0877241),
        (0.986694, 0.705547, 0.0956893),
        (0.986175, 0.713146, 0.103868),
        (0.985565, 0.720775, 0.11223),
        (0.984863, 0.72842, 0.12079),
        (0.98407, 0.73608, 0.129534),
        (0.9832, 0.743755, 0.13846),
        (0.982223, 0.751446, 0.14757),
        (0.98117, 0.759136, 0.156863),
        (0.980026, 0.766842, 0.166354),
        (0.978805, 0.774548, 0.176043),
        (0.977493, 0.782254, 0.185916),
        (0.976104, 0.789975, 0.196017),
        (0.97464, 0.797696, 0.206332),
        (0.973083, 0.805402, 0.216876),
        (0.971466, 0.813123, 0.227665),
        (0.969787, 0.820829, 0.238682),
        (0.968048, 0.828519, 0.249973),
        (0.966247, 0.836194, 0.26154),
        (0.964401, 0.843854, 0.273396),
        (0.962524, 0.851469, 0.285542),
        (0.960632, 0.859068, 0.298009),
        (0.958724, 0.866621, 0.310826),
        (0.956832, 0.874128, 0.32398),
        (0.955001, 0.881575, 0.337469),
        (0.953216, 0.888945, 0.35137),
        (0.951553, 0.896223, 0.365621),
        (0.950011, 0.90341, 0.38027),
        (0.948684, 0.910475, 0.395285),
        (0.947601, 0.917403, 0.410666),
        (0.946807, 0.924163, 0.426368),
        (0.946395, 0.930755, 0.442374),
        (0.94641, 0.937163, 0.458595),
        (0.946899, 0.943343, 0.474968),
        (0.947936, 0.949325, 0.491432),
        (0.949538, 0.955062, 0.507866),
        (0.951736, 0.960586, 0.524208),
        (0.954528, 0.965896, 0.540368),
        (0.9579, 0.971008, 0.556268),
        (0.961807, 0.975921, 0.571923),
        (0.966247, 0.980682, 0.587213),
        (0.97116, 0.985275, 0.602152),
        (0.976516, 0.989746, 0.616754),
        (0.982254, 0.99411, 0.631022),
        (0.988357, 0.998367, 0.644923)
    ]

    # 黄灰蓝
    colors_origin_YellowGrayBlue = [
    (0.301961, 0.0470588, 0.0901961),
    (0.324483, 0.045182, 0.0826886),
    (0.347005, 0.0433051, 0.0751812),
    (0.369528, 0.0414282, 0.0676738),
    (0.39205, 0.0395514, 0.0601663),
    (0.415335, 0.042298, 0.0542),
    (0.438804, 0.0460517, 0.0485695),
    (0.462257, 0.0498054, 0.0429389),
    (0.485725, 0.0535592, 0.0373083),
    (0.508583, 0.0639353, 0.0334936),
    (0.531106, 0.0780194, 0.0306706),
    (0.553628, 0.0920882, 0.027863),
    (0.576135, 0.106172, 0.0250401),
    (0.59649, 0.119799, 0.0226596),
    (0.614298, 0.132921, 0.0207828),
    (0.632105, 0.146059, 0.0189059),
    (0.649928, 0.159182, 0.0170291),
    (0.668009, 0.172564, 0.0148928),
    (0.686778, 0.186648, 0.0120851),
    (0.705547, 0.200717, 0.00926223),
    (0.7243, 0.214801, 0.00645457),
    (0.742321, 0.228977, 0.00383001),
    (0.753582, 0.243992, 0.00288396),
    (0.764843, 0.258991, 0.00195315),
    (0.776104, 0.274006, 0.0010071),
    (0.787366, 0.289021, 7.62951e-05),
    (0.804685, 0.310094, 0.00259403),
    (0.822507, 0.331685, 0.00541695),
    (0.84033, 0.353262, 0.00822461),
    (0.858167, 0.374853, 0.0110475),
    (0.869718, 0.394339, 0.0145571),
    (0.879103, 0.413107, 0.0183108),
    (0.888487, 0.431876, 0.0220645),
    (0.897871, 0.450645, 0.0258183),
    (0.904082, 0.467292, 0.0300908),
    (0.907836, 0.482307, 0.0347906),
    (0.911589, 0.497322, 0.0394751),
    (0.915343, 0.512337, 0.0441749),
    (0.918364, 0.526986, 0.049958),
    (0.920241, 0.54107, 0.0574655),
    (0.922118, 0.555138, 0.0649577),
    (0.923995, 0.569223, 0.0724651),
    (0.92607, 0.58349, 0.0805676),
    (0.928893, 0.598505, 0.0908827),
    (0.931701, 0.613519, 0.101198),
    (0.934524, 0.628534, 0.111528),
    (0.937301, 0.643565, 0.121981),
    (0.939178, 0.65951, 0.13698),
    (0.941054, 0.675441, 0.15198),
    (0.942931, 0.691386, 0.166979),
    (0.944808, 0.707317, 0.181979),
    (0.946685, 0.721691, 0.196994),
    (0.948562, 0.73576, 0.212009),
    (0.950439, 0.749844, 0.227024),
    (0.952316, 0.763912, 0.242039),
    (0.954818, 0.777996, 0.259541),
    (0.957626, 0.792065, 0.278309),
    (0.960449, 0.806149, 0.297078),
    (0.963256, 0.820218, 0.315846),
    (0.965164, 0.833387, 0.336904),
    (0.966094, 0.845579, 0.360357),
    (0.967041, 0.857786, 0.383825),
    (0.967971, 0.869978, 0.407279),
    (0.968917, 0.881315, 0.430167),
    (0.969848, 0.8907, 0.451743),
    (0.970794, 0.900084, 0.473335),
    (0.971725, 0.909468, 0.494911),
    (0.972793, 0.918608, 0.516258),
    (0.97467, 0.926116, 0.535958),
    (0.976547, 0.933623, 0.555673),
    (0.978424, 0.941131, 0.575372),
    (0.980301, 0.948638, 0.595087),
    (0.980392, 0.95436, 0.613001),
    (0.980392, 0.959991, 0.630838),
    (0.980392, 0.965621, 0.648661),
    (0.980392, 0.971252, 0.666499),
    (0.981842, 0.975433, 0.686473),
    (0.983719, 0.979187, 0.707103),
    (0.98558, 0.98294, 0.727733),
    (0.987457, 0.986694, 0.748348),
    (0.987655, 0.988235, 0.771221),
    (0.986679, 0.988235, 0.795666),
    (0.985702, 0.988235, 0.820096),
    (0.984726, 0.988235, 0.844541),
    (0.947036, 0.947036, 0.886),
    (0.932586, 0.932586, 0.866133),
    (0.918135, 0.918135, 0.846265),
    (0.903685, 0.903685, 0.826398),
    (0.889235, 0.889174, 0.80676),
    (0.874784, 0.873808, 0.790494),
    (0.860319, 0.858442, 0.774228),
    (0.845853, 0.843076, 0.757961),
    (0.831388, 0.82771, 0.74168),
    (0.818906, 0.813672, 0.727398),
    (0.807172, 0.800122, 0.713848),
    (0.795422, 0.786587, 0.700313),
    (0.783688, 0.773037, 0.686763),
    (0.771939, 0.760174, 0.673899),
    (0.760189, 0.748425, 0.66215),
    (0.74844, 0.736675, 0.650401),
    (0.73669, 0.724926, 0.638651),
    (0.724987, 0.713176, 0.626947),
    (0.714153, 0.701442, 0.616114),
    (0.703304, 0.689693, 0.605264),
    (0.69247, 0.677958, 0.59443),
    (0.681636, 0.666224, 0.583597),
    (0.670787, 0.653834, 0.572747),
    (0.659953, 0.641184, 0.561913),
    (0.649104, 0.628519, 0.551064),
    (0.638254, 0.615869, 0.540215),
    (0.627085, 0.603555, 0.529366),
    (0.615335, 0.591806, 0.518532),
    (0.603601, 0.580072, 0.507698),
    (0.591852, 0.568322, 0.496864),
    (0.580163, 0.556588, 0.486046),
    (0.570214, 0.544839, 0.476097),
    (0.560281, 0.533089, 0.466163),
    (0.550332, 0.52134, 0.456214),
    (0.540383, 0.50959, 0.446265),
    (0.53106, 0.498451, 0.437568),
    (0.522026, 0.487602, 0.429435),
    (0.512993, 0.476768, 0.421302),
    (0.503944, 0.465919, 0.413169),
    (0.495232, 0.455695, 0.405035),
    (0.487098, 0.446662, 0.396902),
    (0.478965, 0.437629, 0.388769),
    (0.470848, 0.428611, 0.380652),
    (0.462715, 0.419577, 0.372519),
    (0.455482, 0.412345, 0.366201),
    (0.448249, 0.405112, 0.359869),
    (0.441016, 0.397879, 0.353536),
    (0.433799, 0.390661, 0.347219),
    (0.427161, 0.383429, 0.340887),
    (0.420844, 0.376196, 0.334569),
    (0.414527, 0.368978, 0.328252),
    (0.408194, 0.361761, 0.32192),
    (0.401587, 0.354238, 0.315892),
    (0.394354, 0.346105, 0.310475),
    (0.387121, 0.337972, 0.305043),
    (0.379889, 0.329824, 0.299626),
    (0.372656, 0.321691, 0.294209),
    (0.366323, 0.315343, 0.287892),
    (0.360006, 0.309026, 0.281575),
    (0.353689, 0.302708, 0.275257),
    (0.347356, 0.296376, 0.268925),
    (0.341039, 0.289479, 0.262608),
    (0.334707, 0.282246, 0.256275),
    (0.328374, 0.275013, 0.249943),
    (0.322057, 0.267781, 0.243626),
    (0.31545, 0.260548, 0.237293),
    (0.308232, 0.25333, 0.230976),
    (0.300999, 0.246098, 0.224659),
    (0.293782, 0.23888, 0.218326),
    (0.286549, 0.231647, 0.212009),
    (0.279332, 0.22443, 0.205676),
    (0.272099, 0.217197, 0.199359),
    (0.264866, 0.209964, 0.193027),
    (0.257633, 0.202731, 0.186709),
    (0.25153, 0.196063, 0.181506),
    (0.246113, 0.189746, 0.176989),
    (0.240696, 0.183429, 0.172473),
    (0.235279, 0.177096, 0.167956),
    (0.229343, 0.170779, 0.162936),
    (0.22211, 0.164446, 0.156603),
    (0.214878, 0.158129, 0.150286),
    (0.20766, 0.151797, 0.143954),
    (0.200427, 0.145464, 0.137621),
    (0.188952, 0.156146, 0.167864),
    (0.177203, 0.167895, 0.200381),
    (0.165469, 0.179629, 0.232883),
    (0.153719, 0.191379, 0.2654),
    (0.152636, 0.200244, 0.283146),
    (0.158663, 0.207202, 0.291035),
    (0.164691, 0.21416, 0.298909),
    (0.170718, 0.221103, 0.306798),
    (0.17673, 0.228061, 0.314672),
    (0.182757, 0.235019, 0.32256),
    (0.188785, 0.241962, 0.330434),
    (0.194812, 0.24892, 0.338323),
    (0.200778, 0.25594, 0.346273),
    (0.206332, 0.263355, 0.354604),
    (0.211902, 0.270771, 0.362951),
    (0.217456, 0.278187, 0.371283),
    (0.223026, 0.285603, 0.379629),
    (0.22858, 0.293004, 0.387976),
    (0.234134, 0.30042, 0.396307),
    (0.239704, 0.307836, 0.404654),
    (0.245258, 0.315251, 0.412985),
    (0.251774, 0.323293, 0.421958),
    (0.258717, 0.33164, 0.431235),
    (0.265675, 0.339986, 0.440513),
    (0.272633, 0.348333, 0.449775),
    (0.279576, 0.35668, 0.459052),
    (0.286534, 0.365026, 0.46833),
    (0.293492, 0.373358, 0.477592),
    (0.30045, 0.381704, 0.48687),
    (0.307607, 0.390051, 0.49604),
    (0.31548, 0.398398, 0.504845),
    (0.323369, 0.406744, 0.513649),
    (0.331243, 0.415091, 0.522469),
    (0.339117, 0.423438, 0.531273),
    (0.347005, 0.431769, 0.540078),
    (0.354879, 0.440116, 0.548882),
    (0.362768, 0.448463, 0.557687),
    (0.370642, 0.456809, 0.566506),
    (0.378882, 0.465507, 0.575311),
    (0.387228, 0.474311, 0.584115),
    (0.395575, 0.483116, 0.59292),
    (0.403922, 0.491936, 0.60174),
    (0.412253, 0.50074, 0.610544),
    (0.4206, 0.509545, 0.619348),
    (0.428946, 0.518349, 0.628153),
    (0.437293, 0.527169, 0.636973),
    (0.445777, 0.536248, 0.646052),
    (0.454582, 0.545983, 0.655787),
    (0.463386, 0.555718, 0.665522),
    (0.472206, 0.565454, 0.675257),
    (0.48101, 0.575189, 0.684993),
    (0.489815, 0.584924, 0.694728),
    (0.498619, 0.594659, 0.704463),
    (0.507439, 0.604395, 0.714199),
    (0.516243, 0.61413, 0.723934),
    (0.525826, 0.623865, 0.732891),
    (0.535561, 0.6336, 0.741695),
    (0.545296, 0.643336, 0.750515),
    (0.555032, 0.653071, 0.759319),
    (0.564767, 0.662806, 0.768124),
    (0.574502, 0.672541, 0.776928),
    (0.584237, 0.682277, 0.785748),
    (0.593973, 0.692012, 0.794553),
    (0.603891, 0.70193, 0.803174),
    (0.614084, 0.712123, 0.811521),
    (0.624277, 0.722316, 0.819867),
    (0.63447, 0.732509, 0.828199),
    (0.644663, 0.742702, 0.836545),
    (0.654856, 0.752895, 0.844877),
    (0.665049, 0.763088, 0.853223),
    (0.675242, 0.773281, 0.86157),
    (0.685435, 0.783474, 0.869902),
    (0.694362, 0.792401, 0.876967),
    (0.703166, 0.801205, 0.883925),
    (0.711986, 0.810025, 0.890883),
    (0.72079, 0.81883, 0.897841),
    (0.729595, 0.827634, 0.904784),
    (0.738399, 0.836439, 0.911742),
    (0.747219, 0.845258, 0.9187),
    (0.756023, 0.854063, 0.925658),
    (0.765896, 0.863508, 0.932815),
    (0.77702, 0.873701, 0.94023),
    (0.788144, 0.883909, 0.947646),
    (0.799268, 0.894102, 0.955062),
    (0.812314, 0.904936, 0.962066),
    (0.831785, 0.917922, 0.96762),
    (0.851255, 0.930907, 0.97319),
    (0.870726, 0.943877, 0.978744),
    (0.890196, 0.956863, 0.984314)
    ]

    colors_origin_BlueGreenOrange = [
    (0.831373, 0.909804, 0.980392),
    (0.805524, 0.895033, 0.974243),
    (0.77969, 0.880262, 0.968093),
    (0.753841, 0.865507, 0.961929),
    (0.735012, 0.853742, 0.955779),
    (0.717784, 0.842664, 0.94963),
    (0.700557, 0.831586, 0.943481),
    (0.681788, 0.820905, 0.939254),
    (0.662119, 0.810452, 0.936172),
    (0.642435, 0.8, 0.933104),
    (0.622766, 0.789548, 0.930022),
    (0.603082, 0.779095, 0.926955),
    (0.583398, 0.768627, 0.923873),
    (0.564034, 0.758633, 0.920806),
    (0.545571, 0.750027, 0.917723),
    (0.527108, 0.741405, 0.914656),
    (0.508659, 0.732799, 0.911574),
    (0.490196, 0.724178, 0.908492),
    (0.471733, 0.715572, 0.905425),
    (0.453285, 0.70695, 0.902342),
    (0.436439, 0.697276, 0.89604),
    (0.419837, 0.687434, 0.889281),
    (0.403235, 0.677592, 0.882506),
    (0.386633, 0.66775, 0.875746),
    (0.370031, 0.657908, 0.868986),
    (0.353429, 0.648081, 0.862226),
    (0.337438, 0.637629, 0.855756),
    (0.322057, 0.626551, 0.849607),
    (0.306676, 0.615473, 0.843458),
    (0.291295, 0.604395, 0.837293),
    (0.275914, 0.593317, 0.831144),
    (0.260533, 0.582238, 0.824994),
    (0.245762, 0.571557, 0.818845),
    (0.235294, 0.563561, 0.812696),
    (0.224842, 0.55555, 0.806531),
    (0.214374, 0.547555, 0.800381),
    (0.203922, 0.539559, 0.794232),
    (0.193454, 0.531563, 0.788083),
    (0.183001, 0.523568, 0.781918),
    (0.17116, 0.512337, 0.77116),
    (0.158877, 0.500053, 0.758877),
    (0.148257, 0.488518, 0.747494),
    (0.144411, 0.480049, 0.739803),
    (0.140566, 0.471595, 0.732113),
    (0.136721, 0.463127, 0.724407),
    (0.132876, 0.454673, 0.716716),
    (0.128862, 0.446677, 0.709422),
    (0.123491, 0.442832, 0.705577),
    (0.118105, 0.438987, 0.701732),
    (0.112718, 0.435142, 0.697887),
    (0.107347, 0.431296, 0.694041),
    (0.101961, 0.427451, 0.690196),
    (0.0988785, 0.418219, 0.677882),
    (0.0958114, 0.408988, 0.665583),
    (0.093431, 0.401846, 0.65536),
    (0.0918898, 0.397238, 0.647669),
    (0.0903487, 0.39263, 0.639994),
    (0.0874342, 0.383856, 0.632303),
    (0.0843519, 0.374624, 0.624613),
    (0.0807355, 0.366476, 0.616907),
    (0.0761273, 0.360311, 0.609216),
    (0.0715038, 0.354162, 0.601526),
    (0.0693523, 0.345556, 0.590143),
    (0.0678264, 0.336339, 0.577859),
    (0.0674296, 0.327886, 0.565942),
    (0.0705119, 0.321721, 0.555169),
    (0.0735943, 0.315572, 0.544396),
    (0.0777447, 0.311574, 0.532555),
    (0.0823529, 0.308492, 0.520241),
    (0.0867475, 0.304723, 0.507942),
    (0.0898146, 0.297032, 0.495644),
    (0.0928817, 0.289357, 0.48336),
    (0.095964, 0.284428, 0.471977),
    (0.0990463, 0.281346, 0.461204),
    (0.102113, 0.278202, 0.450202),
    (0.105196, 0.273594, 0.434836),
    (0.108263, 0.268986, 0.419471),
    (0.110567, 0.265141, 0.405631),
    (0.112108, 0.262058, 0.393332),
    (0.113649, 0.258976, 0.381018),
    (0.113725, 0.255909, 0.368704),
    (0.113725, 0.252827, 0.35639),
    (0.113115, 0.253437, 0.344717),
    (0.111574, 0.259586, 0.333959),
    (0.110033, 0.265736, 0.323201),
    (0.108492, 0.278416, 0.301991),
    (0.106966, 0.292256, 0.278904),
    (0.104494, 0.302876, 0.260441),
    (0.0998856, 0.305959, 0.25275),
    (0.0952621, 0.309041, 0.24506),
    (0.0906538, 0.313268, 0.238529),
    (0.0860456, 0.317876, 0.23238),
    (0.0817426, 0.323095, 0.226841),
    (0.0786603, 0.330785, 0.223758),
    (0.0755932, 0.338476, 0.220691),
    (0.0735027, 0.346181, 0.217609),
    (0.0719768, 0.353872, 0.214527),
    (0.0704356, 0.361563, 0.211917),
    (0.0688945, 0.369238, 0.213458),
    (0.0673533, 0.376928, 0.215),
    (0.0658274, 0.384619, 0.207248),
    (0.0642863, 0.392309, 0.191852),
    (0.0627451, 0.4, 0.176471),
    (0.0645914, 0.403082, 0.171542),
    (0.0664378, 0.406149, 0.166629),
    (0.0682841, 0.409232, 0.1617),
    (0.0701305, 0.412299, 0.156786),
    (0.0719768, 0.415381, 0.151858),
    (0.0738231, 0.418463, 0.146929),
    (0.0756695, 0.42153, 0.142397),
    (0.0775158, 0.424613, 0.138094),
    (0.0793622, 0.42768, 0.133791),
    (0.0811933, 0.430762, 0.129488),
    (0.0830396, 0.433829, 0.125185),
    (0.0848859, 0.436912, 0.120882),
    (0.0876478, 0.440436, 0.117647),
    (0.0931868, 0.445365, 0.117647),
    (0.0987259, 0.450278, 0.117647),
    (0.104265, 0.455207, 0.117647),
    (0.109804, 0.460136, 0.117647),
    (0.115343, 0.465049, 0.117647),
    (0.120882, 0.469978, 0.117647),
    (0.130175, 0.474891, 0.12195),
    (0.140017, 0.47982, 0.126879),
    (0.149859, 0.484733, 0.131792),
    (0.159701, 0.489647, 0.136706),
    (0.169543, 0.494575, 0.141634),
    (0.17937, 0.499489, 0.146548),
    (0.189822, 0.505028, 0.152087),
    (0.2009, 0.511177, 0.158236),
    (0.211978, 0.517327, 0.164385),
    (0.223056, 0.523491, 0.17055),
    (0.234134, 0.529641, 0.176699),
    (0.245212, 0.53579, 0.182849),
    (0.256275, 0.541939, 0.189075),
    (0.267353, 0.548089, 0.19585),
    (0.278431, 0.554253, 0.202609),
    (0.289509, 0.560403, 0.209384),
    (0.300587, 0.566552, 0.216144),
    (0.31165, 0.572702, 0.222919),
    (0.322728, 0.578866, 0.229694),
    (0.334722, 0.585016, 0.236912),
    (0.347021, 0.591165, 0.244297),
    (0.359319, 0.597314, 0.251667),
    (0.371618, 0.603464, 0.259052),
    (0.383917, 0.609613, 0.266423),
    (0.396216, 0.615763, 0.273808),
    (0.409674, 0.622599, 0.281651),
    (0.425055, 0.630594, 0.290257),
    (0.440436, 0.63859, 0.298878),
    (0.455818, 0.646586, 0.307485),
    (0.471199, 0.654597, 0.316106),
    (0.48658, 0.662593, 0.324712),
    (0.501961, 0.670588, 0.333333),
    (0.513756, 0.678279, 0.342046),
    (0.525536, 0.685969, 0.350759),
    (0.537331, 0.69366, 0.359472),
    (0.549126, 0.70135, 0.3682),
    (0.560922, 0.709041, 0.376913),
    (0.572702, 0.716732, 0.385626),
    (0.584497, 0.724422, 0.394339),
    (0.60238, 0.733455, 0.406195),
    (0.631601, 0.744976, 0.42388),
    (0.660807, 0.756512, 0.44155),
    (0.690028, 0.768048, 0.459236),
    (0.719234, 0.779568, 0.476921),
    (0.746929, 0.791684, 0.49575),
    (0.770001, 0.805539, 0.518059),
    (0.793088, 0.819379, 0.540368),
    (0.816159, 0.833234, 0.562692),
    (0.839246, 0.847074, 0.585),
    (0.860075, 0.85835, 0.603449),
    (0.868269, 0.855283, 0.600381),
    (0.876463, 0.852201, 0.597299),
    (0.884657, 0.849134, 0.594232),
    (0.892866, 0.846067, 0.591165),
    (0.901061, 0.842985, 0.588083),
    (0.909255, 0.839918, 0.585016),
    (0.917449, 0.836835, 0.581933),
    (0.920806, 0.831159, 0.57702),
    (0.919265, 0.822858, 0.57026),
    (0.917723, 0.814542, 0.563485),
    (0.916182, 0.806241, 0.55671),
    (0.914656, 0.797925, 0.54995),
    (0.913115, 0.789624, 0.543175),
    (0.911574, 0.781323, 0.536416),
    (0.910033, 0.773007, 0.529641),
    (0.908492, 0.764706, 0.522881),
    (0.906966, 0.756405, 0.516106),
    (0.905425, 0.748089, 0.509346),
    (0.903883, 0.739788, 0.502571),
    (0.902342, 0.731487, 0.495796),
    (0.899428, 0.720867, 0.487877),
    (0.89604, 0.709483, 0.479576),
    (0.892653, 0.6981, 0.471275),
    (0.889265, 0.686732, 0.462974),
    (0.885893, 0.675349, 0.454673),
    (0.882506, 0.663966, 0.446357),
    (0.879118, 0.652583, 0.438056),
    (0.875746, 0.641215, 0.429755),
    (0.872358, 0.629831, 0.421454),
    (0.868971, 0.618448, 0.413153),
    (0.865583, 0.607065, 0.404837),
    (0.862211, 0.595697, 0.396536),
    (0.858824, 0.584314, 0.388235),
    (0.854215, 0.57293, 0.383001),
    (0.849592, 0.561563, 0.377783),
    (0.844984, 0.550179, 0.372549),
    (0.840375, 0.538796, 0.367315),
    (0.835752, 0.527413, 0.362097),
    (0.831144, 0.516045, 0.356863),
    (0.826535, 0.504662, 0.351644),
    (0.821912, 0.493278, 0.34641),
    (0.817304, 0.481895, 0.341176),
    (0.812696, 0.470527, 0.335958),
    (0.808072, 0.459144, 0.330724),
    (0.803464, 0.447761, 0.32549),
    (0.79762, 0.436454, 0.319265),
    (0.788098, 0.425391, 0.310048),
    (0.778561, 0.414313, 0.300816),
    (0.769024, 0.40325, 0.291585),
    (0.759487, 0.392172, 0.282368),
    (0.74995, 0.381094, 0.273136),
    (0.740429, 0.370031, 0.263905),
    (0.730892, 0.358953, 0.254688),
    (0.721355, 0.34789, 0.245457),
    (0.711818, 0.336812, 0.236225),
    (0.702281, 0.325734, 0.227008),
    (0.692744, 0.314672, 0.217777),
    (0.683223, 0.303593, 0.20856),
    (0.673381, 0.292988, 0.200244),
    (0.663218, 0.282826, 0.192859),
    (0.653071, 0.272679, 0.185473),
    (0.642924, 0.262531, 0.178088),
    (0.632761, 0.252369, 0.170718),
    (0.622614, 0.242222, 0.163333),
    (0.612467, 0.232074, 0.155947),
    (0.602304, 0.221912, 0.148562),
    (0.592157, 0.211765, 0.141176),
    (0.58201, 0.201617, 0.133791),
    (0.571847, 0.191455, 0.126406),
    (0.5617, 0.181308, 0.11902),
    (0.551553, 0.17116, 0.111635),
    (0.540703, 0.158465, 0.102419),
    (0.529641, 0.144945, 0.0925765),
    (0.518578, 0.131411, 0.0827344),
    (0.5075, 0.117891, 0.0728923),
    (0.496437, 0.104356, 0.0630655),
    (0.485359, 0.0908217, 0.0532235),
    (0.476829, 0.0779889, 0.0442969),
    (0.472511, 0.0663005, 0.0369116),
    (0.468208, 0.054612, 0.0295415),
    (0.463905, 0.0429084, 0.0221561),
    (0.459602, 0.03122, 0.0147707),
    (0.455283, 0.0195315, 0.00738537),
    (0.45098, 0.00784314, 0)
    ]

    # 原始数据字典
    colors_origin_dict = {
        ColorType.Inferno : colors_origin_Inferno, 
        ColorType.BlueGreenOrange : colors_origin_BlueGreenOrange,
        ColorType.YellowGrayBlue : colors_origin_YellowGrayBlue
    }

    # 参数：色卡类型，以及层数
    def __init__(self, _type : ColorType, _count : int = 1 ):
        # 初始化实例变量
        self.color_type = _type
        self.level_Count = _count
        self.color_use_solution = []
        self.generateColorSolution(self.color_type, self.level_Count)

    # 初始化方法，用来生成色卡方案
    def generateColorSolution(self, _type : ColorType, _num: int):
        if _num < 1 or _num > 256:
            _num = 256

        self.color_use_solution.clear()
        for i in range(_num):
            index = int(i / _num * 255)
            self.color_use_solution.append(ColorLookUpTable.colors_origin_dict[_type][index])
        # print('color solution level count is ' ,len(self.color_use_solution))

    # 通过最大最小值获取颜色
    def getColor(self, _inValue, _minValue, _maxValue):
        if len(self.color_use_solution) == 0:
            return (0,0,0)
        
        if _minValue == _maxValue:
            return (0,0,0)
        
        if _minValue < 0 and _maxValue <= 0 :
            if _inValue <= _minValue:
                return self.color_use_solution[len(self.color_use_solution) - 1]
            elif _inValue >= _maxValue:
                return self.color_use_solution[0]
            else :
                return self.color_use_solution[int(_maxValue - _inValue) * (_maxValue - _minValue) * len(self.color_use_solution)]

        elif _minValue < 0 and _maxValue > 0:
            if _inValue <= _minValue:
                return self.color_use_solution[len(self.color_use_solution) - 1]
            elif _inValue >= _maxValue:
                return self.color_use_solution[len(self.color_use_solution) - 1]
            else:
                if _inValue < 0:
                    self.color_use_solution[int((0 - _inValue) / (0 - _minValue))]
                elif _inValue > 0:
                    self.color_use_solution[int(_inValue / _maxValue)]
                else:
                    return self.color_use_solution[0]
        elif _minValue >= 0 and _maxValue > 0:
            if _inValue <= _minValue:
                return self.color_use_solution[0]
            elif _inValue >= _maxValue:
                return self.color_use_solution[len(self.color_use_solution) - 1]
            else:
                return self.color_use_solution[int((_inValue - _minValue)/(_maxValue-_minValue))]
        else:
            return self.color_use_solution[0]
        
    # 通过最大最小值返回色卡信息
    def getColorList(self, _minValue, _maxValue):
        color_points = []
        if _minValue == _maxValue:
            for i in range(self.level_Count):
                color_points.append(_minValue)
                color_points.append(self.color_use_solution[i][0])
                color_points.append(self.color_use_solution[i][1])
                color_points.append(self.color_use_solution[i][2])
            return color_points
        
        elif _minValue < 0 and _maxValue <= 0:
            interval = (_maxValue - _minValue) / self.level_Count
            for i in range(self.level_Count):
                color_points.append( i * interval + _minValue)
                color_points.append(self.color_use_solution[self.level_Count - i - 1][0])
                color_points.append(self.color_use_solution[self.level_Count - i - 1][1])
                color_points.append(self.color_use_solution[self.level_Count - i - 1][2])

            return color_points
        
        elif _minValue >= 0 and _maxValue > 0:
            interval = (_maxValue - _minValue) / self.level_Count
            for i in range(self.level_Count):
                color_points.append( i * interval + _minValue)
                color_points.append(self.color_use_solution[i][0])
                color_points.append(self.color_use_solution[i][1])
                color_points.append(self.color_use_solution[i][2])
            return color_points
        else:
            interval_below = (0 - _minValue) / self.level_Count
            interval_above = (_maxValue - 0) / self.level_Count
            for i in range(self.level_Count):
                color_points.append( i * interval_below + _minValue)
                color_points.append(self.color_use_solution[self.level_Count - i - 1][0])
                color_points.append(self.color_use_solution[self.level_Count - i - 1][1])
                color_points.append(self.color_use_solution[self.level_Count - i - 1][2])

            for i in range(self.level_Count):
                color_points.append( i * interval_above + 0)
                color_points.append(self.color_use_solution[i][0])
                color_points.append(self.color_use_solution[i][1])
                color_points.append(self.color_use_solution[i][2])

            return color_points


    # 通过最大最小值获取不透明度
    def getOpacity(self, _inValue, _minValue, _maxValue):
        if _minValue <= 0 and _maxValue <= 0:
            minValue = abs(_maxValue)
            maxValue = abs(_minValue)
        elif _minValue >= 0 and _maxValue >= 0:
            minValue = _minValue
            maxValue = _maxValue
        else:
            minValue = 0
            maxValue = max(abs(_minValue), _maxValue)
        value = abs(_inValue)
        
        # 最大最小值如果差距太小，直接返回不透明度为0
        if maxValue - minValue < 0.000001:
            return 0
        
        if value >= maxValue:
            return 1
        elif value <= minValue:
            return 0
        else:
            return (value - minValue) / (maxValue - minValue)
        
    # 通过最大最小值获取不透明度列表
    def getOpacityList(self, _minValue, _maxValue):
        opacity_points = []
        if _minValue == _maxValue:
            for i in range(self.level_Count):
                opacity_points.append(_minValue)
                opacity_points.append(0)
                opacity_points.append(0)
                opacity_points.append(0)
            return opacity_points;

        elif _minValue < 0 and _maxValue <= 0:
            interval = (_maxValue - _minValue) / self.level_Count
            opacity_interval = 1 / self.level_Count
            for i in range(self.level_Count):
                opacity_points.append( i * interval + _minValue)
                opacity_points.append((self.level_Count - i - 1) * opacity_interval)
                opacity_points.append((self.level_Count - i - 1) * opacity_interval)
                opacity_points.append((self.level_Count - i - 1) * opacity_interval)

            return opacity_points
        
        elif _minValue >= 0 and _maxValue > 0:
            interval = (_maxValue - _minValue) / self.level_Count
            opacity_interval = 1 / self.level_Count
            for i in range(self.level_Count):
                opacity_points.append(i * interval + _minValue)
                opacity_points.append(i * opacity_interval)
                opacity_points.append(i * opacity_interval)
                opacity_points.append(i * opacity_interval)

            return opacity_points
        else:   # 最小值为负数，最大值为正数
            interval_below = (0 - _minValue) / self.level_Count
            interval_above = (_maxValue - 0) / self.level_Count
            opacity_interval = 1 / self.level_Count
            for i in range(self.level_Count):
                opacity_points.append( i * interval_below + _minValue)
                opacity_points.append((self.level_Count - i - 1) * opacity_interval)
                opacity_points.append((self.level_Count - i - 1) * opacity_interval)
                opacity_points.append((self.level_Count - i - 1) * opacity_interval)

            for j in range(self.level_Count):
                opacity_points.append(j * interval_above)
                opacity_points.append(j * opacity_interval)
                opacity_points.append(j * opacity_interval)
                opacity_points.append(j * opacity_interval)

            return opacity_points

# 使用方法
#obj = ColorLookUpTable(ColorType.Inferno, 40)
#print('color: ', obj.getColor(0.5, 0, 1))
# print('opacity: ', obj.getOpacity(0.5, 0, 1))
#print('color list: ', obj.getColorList(0, 1))
#print('color list: ', obj.getColorList(-1, -0.5))
#print('color list: ', obj.getColorList(-1, 1))
#print('opacity list: ', obj.getOpacityList(1, 2))
#print('opacity list: ', obj.getOpacityList(-1, 0))
#print('opacity list: ', obj.getOpacityList(-3, 3))